package com.xuhnagchen.automation;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.util.Properties;

@SpringBootApplication
@MapperScan("com.xuhnagchen.automation.mapper")//使用MapperScan批量扫描所有的Mapper接口；
public class AutomationApplication {

    public static void main(String[] args) {
        SpringApplication.run(AutomationApplication.class, args);
    }

    public static String getProperties(String key) {
        //从application.properties文件中获取用到的参数;
        String value = null;
        Resource resource = new ClassPathResource("application.properties");
        Properties props = null;
        try {
            props = PropertiesLoaderUtils.loadProperties(resource);
            value = props.getProperty(key);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return value;
    }
}
